require(['./config'],()=>{
    require(['jquery'],()=>{
        class Register{
            constructor(){
                this.init()
            }
        init(){
             $('#oklogin').on('click',function(){
                  const name=$('#nameInput').val(),
                   pwd=$('#pwdInput').val(),
                   userinfo = { name, pwd }
                   let userList = localStorage.getItem('userList')
                   if(userList){
                        userList=JSON.parse(userList)
                        let is =userList.some((user)=>{
                            return name==user.name
                        })
                        if(is){
                            alert('注册名重复，请重新输入')
                        
                        }else{
                            userList.push(userinfo)
                            localStorage.setItem('userList',JSON.stringify(userList))
                            alert('注册成功，即将跳转登录页面')
                            location.href="/html/login.html"
                        }
                   }else{
                    let arr=[userinfo]
                    localStorage.setItem('userList',JSON.stringify(arr))
                    alert('注册成功，即将跳转登录页面')
                    location.href="/html/login.html"
                 }
             })
                  
            }    
            
        }
        new Register()
    })
})